package com.twetec.cms.adapter.pc.backend.controller.website;

import com.twetec.cms.adapter.pc.backend.util.beetl.html.BeetlStaticHtml;
import com.twetec.cms.adapter.pc.backend.response.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;


@Api(tags = "静态化模块(测试)")
@RestController
@RequestMapping("/website/to-static")
public class ToStaticController {

    @Autowired
    BeetlStaticHtml beetlStaticHtml;


    @ApiOperation(value = "静态化站点", notes = "静态化站点")
    @GetMapping("/site")
    public R site(@ApiParam(value = "站点id", required = true, example = "121321") @RequestParam(required = false) Long siteId) {

        return R.success().msg("静态化站点成功");
    }


    @ApiOperation(value = "test", notes = "test")
    @GetMapping("/test")
    public R test(@ApiParam(value = "templateFilePath", required = true, example = "\\123456789101213\\template\\helloworld\\index.html") @RequestParam(required = false) String templateFilePath,
                  @ApiParam(value = "staticHtmlFilePath", required = true, example = "D:\\UploadFile\\123456789101213\\html\\index.html") @RequestParam(required = false) String staticHtmlFilePath
                  ) {
        Map<String, Object> attr = new HashMap<>();

        attr.put("name", "张三");
        attr.put("say", "你好");

        beetlStaticHtml.create(templateFilePath, staticHtmlFilePath, attr);

        return R.success().msg("静态化站点成功");
    }

}
